package com.wsj.service.impl;

import java.util.List;

import com.wsj.dao.IMagazineDao;
import com.wsj.service.IMagazineServ;
import com.wsj.util.exception.BusinessException;
import com.wsj.util.page.PageResultSet;
import com.wsj.web.subclass.displayBean.Magazine.MagazineExtendBean;
import com.wsj.web.vo.homeSite.Magazine;

public class MagazineServImpl implements IMagazineServ {
	
	private IMagazineDao   magazineDaoImpl;

	
	public List<Magazine> getByTime(Integer top) throws BusinessException {
		if(top!=null){
			return this.magazineDaoImpl.loadByTime(top);
		}
		return null;
	}
	
	
	public boolean add(Magazine magazine) throws BusinessException {
		
		this.magazineDaoImpl.add(magazine);
		return true;
	}

	public boolean delete(Integer id) throws BusinessException {
		
		this.magazineDaoImpl.delete(id);
		return true;

	}

	public Magazine getMagazineById(Integer id) throws BusinessException {
		
		Magazine magazine=this.magazineDaoImpl.getMagazineById(id);
		return magazine;
	}

	public Magazine getMagazineByName(String title) throws BusinessException {
		// TODO Auto-generated method stub
		Magazine magazine=this.magazineDaoImpl.getMagazineByName(title);
		return magazine;
	}

	public PageResultSet loadMagazineByParam(String title, String content,
			String keyword, Integer hits, String username, Integer iscommend,
			Short isImg, Short shanchu, Short toptitle, Short gs, Short sh,int page,int pageSize,Integer magazineNameid,Integer magazineClassid )
			throws BusinessException {
		// TODO Auto-generated method stub
		PageResultSet pageResultSet=this.magazineDaoImpl.loadMagazineByParam(title, content, keyword, hits, username, iscommend, isImg, shanchu, toptitle, gs, sh,page,pageSize,magazineNameid,magazineClassid);
		return pageResultSet;
	}
	public PageResultSet loadMagazineByMagazineExtendBean(MagazineExtendBean magazineExtendBean)
	throws BusinessException {
		// TODO Auto-generated method stub
		PageResultSet pageResultSet=this.magazineDaoImpl.loadMagazineByMagazineExtendBean(magazineExtendBean);
		return pageResultSet;
	}

	public boolean update(Magazine magazine) throws BusinessException {
		
		this.magazineDaoImpl.update(magazine);
		
		return true;

	}

	public IMagazineDao getMagazineDaoImpl() {
		return magazineDaoImpl;
	}

	public void setMagazineDaoImpl(IMagazineDao magazineDaoImpl) {
		this.magazineDaoImpl = magazineDaoImpl;
	}

	/*****
	 * 通过 杂志栏目名 id 和前几个,获取前几个图片的杂志列表
	 */
	public List<Magazine> loadPicMagazineListByMagazineNameId(Integer magazineNameId , Integer top) throws BusinessException 
	{
		return  this.getMagazineDaoImpl().loadPicMagazineListByMagazineNameIdDao(magazineNameId ,  top);
		
	}


	public List<Magazine> getByNameId(Integer nameId, Integer top) throws BusinessException {
		
		return this.getMagazineDaoImpl().loadByNameId(nameId, top);
	}

}
